/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package concreteBuilders;

import builderProduct.AbstractBuilder;
import java.text.AttributedCharacterIterator.Attribute;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Vector;
import operacoes2.Operacao;

/**
 *
 * @author Rente
 */
public class TextFileBuilder extends AbstractBuilder {

    Vector<Operacao> vector;

    @Override
    public void buildCabecalho() {
        System.out.println("SOU TXT -> Vou construir o cabeçalho");

    }

    @Override
    public void buildCorpo() {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd#HH:mm:ss");

        System.out.println("SOU TXT -> Vou construir o corpo");
        vector = super.getVal();
        StringBuffer corpo = new StringBuffer();
        for (Operacao operacao : vector) {

            corpo.append("Data: " + dateFormat.format(operacao.getData()) + " -> "+operacao.toString() + " \n");
        }
        fb.setCorpo(corpo);

    }

    @Override
    public void buildExtensao() {
        fb.setExtensao("txt");
    }
}
